// ReSharper disable RedundantUsingDirective
// ReSharper disable DoNotCallOverridableMethodsInConstructor
// ReSharper disable InconsistentNaming
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable PartialMethodWithSinglePart
// ReSharper disable RedundantNameQualifier

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
//using DatabaseGeneratedOption = System.ComponentModel.DataAnnotations.DatabaseGeneratedOption;

namespace wUniApp.MVC.App_Data
{
    // Customers
    internal partial class CustomerConfiguration : EntityTypeConfiguration<Customer>
    {
        public CustomerConfiguration(string schema = "")
        {
            ToTable("Customers");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(x => x.FirstName).HasColumnName("FirstName").IsRequired().HasMaxLength(50);
            Property(x => x.LastName).HasColumnName("LastName").IsRequired().HasMaxLength(50);
            Property(x => x.Age).HasColumnName("Age").IsRequired();
            Property(x => x.MonthlyIncome).HasColumnName("MonthlyIncome").IsRequired().HasPrecision(19,4);
            Property(x => x.ChildsCount).HasColumnName("ChildsCount").IsRequired();
            Property(x => x.ProductId).HasColumnName("ProductId").IsRequired();
            Property(x => x.Notes).HasColumnName("Notes").IsOptional().HasMaxLength(1024);
            Property(x => x.Email).HasColumnName("Email").IsOptional().HasMaxLength(50);

            // Foreign keys
            HasRequired(a => a.Product).WithMany(b => b.Customers).HasForeignKey(c => c.ProductId); // FK_Customers_Products
            InitializePartial();
        }
        partial void InitializePartial();
    }

}
